package model.game;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import model.area.Field;
import model.person.Person;

public class Match {
	private Team teamA;
	private Team teamB;
	private int goalsA = 0;
	private int goalsB = 0;
	private Map<Person, Integer> yellowCards = new HashMap<Person, Integer>();
	private Map<Person, Integer> redCards = new HashMap<Person, Integer>();
	private List<Person> referees = new ArrayList<Person>();
	private Field field;
	private String startTime;

	public Match(Team teamA, Team teamB, Field f, String startTime) {
		this.teamA = teamA;
		this.teamB = teamB;
		this.field = f;
		this.startTime = startTime;
	}

	public Team getTeamA() {
		return teamA;
	}

	public void setTeamA(Team teamA) {
		this.teamA = teamA;
	}

	public Team getTeamB() {
		return teamB;
	}

	public void setTeamB(Team teamB) {
		this.teamB = teamB;
	}

	public int getGoalsTeamA() {
		return goalsA;
	}

	public void addGoalTeamA() {
		goalsA++;
	}

	public int getGoalsTeamB() {
		return goalsB;
	}

	public void addGoalsTeamB() {
		goalsB++;
	}

	public Map<Person, Integer> getYellowCards() {
		return yellowCards;
	}

	public void addYellowCard(Person person) {
		if (!yellowCards.keySet().contains(person)) {
			yellowCards.put(person, 1);
		} else {
			for (Person p : yellowCards.keySet()) {
				if (p.equals(person)) {
					int i = yellowCards.get(p);
					yellowCards.put(p, i++);
				}
			}
		}

	}

	public Map<Person, Integer> getRedCards() {
		return redCards;
	}

	public void addRedCard(Person person) {
		if (!redCards.keySet().contains(person)) {
			redCards.put(person, 1);
		} else {
			for (Person p : redCards.keySet()) {
				if (p.equals(person)) {
					int i = redCards.get(p);
					redCards.put(p, i++);
				}
			}
		}
	}

	public List<Person> getReferees() {
		return referees;
	}

	public void addReferee(Person referee) {
		referees.add(referee);
	}

	public Field getField() {
		return field;
	}

	public void setField(Field field) {
		this.field = field;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

}
